package com.rew.canteenbox.bases;

import android.app.Application;
import com.rew.canteenbox.http.HttpClient;
import com.rew.canteenbox.models.Circle;
import com.rew.canteenbox.models.Dishes;
import com.rew.canteenbox.models.Orders;

import java.util.List;

/**
 *  App公共数据集装.
 *
 * Created by HuiWen Ren on 2016/11/14.
 */
public class AppData extends Application {

    public static final int GRAY = 0xFF858585;
    public static final int ACTIVE = 0xFF3366FF;

    @Override
    public void onCreate() {
        super.onCreate();
        HttpClient.init(this);
//        ImageUtil.init(this, FileManager.getHomeDir());
//        TextToast.init(this);
//        NetworkUtil.init(this);
//        CrashHandler.getInstance().init(this);
    }

    // 订单链表.
    private List<Orders> ordersList;

    // 菜品链表.
    private List<Dishes> dishesList;

    // 朋友圈链表
    private List<Circle> circleList;

    //  获取朋友圈所在位置.
    public Circle findCiecleNum(int i){
        return circleList.get(i);
    }

    // 添（追）加订单.
    public void addOrder(Dishes dishes) {
       Orders.addOrder(this.ordersList,dishes);
    }

    // 减少（取消）订单.
    public void minusOrder(Dishes dishes) {
        Orders.minusOrder(this.ordersList,dishes);
    }

    // 获取订单所在位置.
    private int findDishesPosition(Dishes dishes){
        return Orders.findDishesPosition(this.ordersList,dishes);
    }

    // 获取当前订购数目.
    public int getNum(Dishes dishes) {
        return Orders.getNum(ordersList, dishes);
    }

    public List<Orders> getOrdersList() {
        return ordersList;
    }

    public void setOrdersList(List<Orders> ordersList) {
        this.ordersList = ordersList;
    }

    public List<Dishes> getDishesList() {
        return dishesList;
    }

    public void setDishesList(List<Dishes> dishesList) {
        this.dishesList = dishesList;
    }

    public List<Circle> getCircleList() {
        return circleList;
    }

    public void setCircleList(List<Circle> circleList) {
        this.circleList = circleList;
    }

    public void addLike(int position) {
        circleList.get(position).likeNum++;
    }

    public void disLike(int position) {
        circleList.get(position).likeNum--;
    }

    public void chLike(int position) {
        circleList.get(position).likeMark
                = !circleList.get(position).likeMark;
    }
}
